#include "color.h"

namespace rt
{


Color::Color()
{
    d[0]=0;d[1]=0;d[2]=0;
}

Color::Color(double a,double b,double c)
{
    d[0]=a;d[1]=b;d[2]=c;
}

boost::array<double,3> Color::data()
{
    return d;
}

double Color::data(int n)
{
    return d[n];
}

void Color::setData(int n,double a)
{
    d[n]=a;
}

void Color::setZeros()
{
    d[0]=0;d[1]=0;d[2]=0;
}

void Color::setOnes()
{
    d[0]=1.0;d[1]=1.0;d[2]=1.0;
}

void Color::setAll(double a,double b,double c){
    d[0]=a;d[1]=b;d[2]=c;
}

double Color::getRed()
{
    return d[0];
}

double Color::getGreen()
{
    return d[1];
}

double Color::getBlue()
{
    return d[2];
}

Color Color::operator+(Color &a)
{
    return Color(a.data(0)+d[0],a.data(1)+d[1],a.data(2)+d[2]);

}

Color Color::operator-(Color &a)
{
    return Color(a.data(0)-d[0],a.data(1)-d[1],a.data(2)-d[2]);
}

double Color::operator*(Color &a)
{
    return double(a.data(0)*d[0]+a.data(1)*d[1]+a.data(2)*d[2]);
}

Color Color::operator*(double a)
{
    return Color(d[0]*a,d[1]*a,d[2]*a);
}

Color Color::operator^ (Color &a)
{
    return Color(d[1]*a.data(2)-d[2]*a.data(1),
            d[2]*a.data(0)-d[0]*a.data(2),
            d[0]*a.data(1)-d[1]*a.data(0));
}

void Color::operator=(Color a)
{
    this->setData(0,a.data(0));
    this->setData(1,a.data(1));
    this->setData(2,a.data(2));
}
}
